import variables from '@/styles/element-variables.scss'
// import defaultSettings from '@/settings'

// const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  sidebar: {
    opened: true,
    withoutAnimation: false
  },
  theme: variables.theme,
  showSettings: true,
  tagsView: true,
  fixedHeader: false,
  sidebarLogo: true
}

const mutations = {
  TOGGLE_SIDEBAR: state => {
    state.sidebar.opened = !state.sidebar.opened
    state.sidebar.withoutAnimation = false
    /* if (state.sidebar.opened) {
      Cookies.set('sidebarStatus', 1)
    } else {
      Cookies.set('sidebarStatus', 0)
    } */
  },
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
  toggleSideBar({ commit }) {
    commit('TOGGLE_SIDEBAR')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

